﻿using AgencyManagerSystem.Model;
using System.Collections.Generic;
using System.Linq;

namespace AgencyManagerSystem.DataFetcher
{
    public class CustomerFetcher : BaseFetcher<CustomerModel>
    {
        public CustomerFetcher() : base()
        {

        }
        public CustomerModel GetByCode(int retail,string code)
        {
            Condition[] conditions = new Condition[] { new Condition() { Key = "Code", Op = "=", Value = code } ,
                                                       new Condition() { Key = "Retail", Op = "=", Value = retail }};
            var list = List(conditions);
            if (list.Count > 0)
                return list.First();
            else
                return null;
        }

        public IList<CustomerModel> ListByRetail(int retail,string customername)
        {
            Condition[] conditions = new Condition[] { new Condition() { Key = "Retail", Op = "=", Value = retail }, new Condition() { Key = "Name", Op = "like", Value = customername } };
            var list = List(conditions);
            return list;
        }
    }
}
